home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / misc / tri14dev.lha / Triton / Developer / DemoSource / progind.c < prev    next >
C/C++ Source or Header  |  1995-08-25  |  4KB  |  131 lines

  1. /*
  2.  *  Triton - The object oriented GUI creation system for the Amiga
  3.  *  Written by Stefan Zeiger in 1993-1995
  4.  *
  5.  *  (c) 1993-1995 by Stefan Zeiger
  6.  *  You are hereby allowed to use this source or parts
  7.  *  of it for creating programs for AmigaOS which use the
  8.  *  Triton GUI creation system. All other rights reserved.
  9.  *
  10.  *  progind.c - Progress indicator demo
  11.  *
  12.  */
  13.  
  14.  
  15. /* /////////////////////////////////////////////////////////////////////////////////////////////////////// */
  16. /* ////////////////////////////////////////////////////////////////////////////////// Include our stuff // */
  17. /* /////////////////////////////////////////////////////////////////////////////////////////////////////// */
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22.  
  23. #include <libraries/triton.h>
  24.  
  25. #ifdef __GNUC__
  26. #ifndef __OPTIMIZE__
  27. #include <clib/triton_protos.h>
  28. #include <clib/dos_protos.h>
  29. #include <clib/intuition_protos.h>
  30. #else
  31. #include <inline/triton.h>
  32. #include <inline/dos.h>
  33. #include <inline/intuition.h>
  34. #endif /* __OPTIMIZE__ */
  35. #else
  36. #include <proto/triton.h>
  37. #include <proto/dos.h>
  38. #include <proto/intuition.h>
  39. #endif /* __GNUC__ */
  40.  
  41.  
  42. /* /////////////////////////////////////////////////////////////////////////////////////////////////////// */
  43. /* ////////////////////////////////////////////////////////////////////////////////////// Window 'main' // */
  44. /* /////////////////////////////////////////////////////////////////////////////////////////////////////// */
  45.  
  46. enum IDs {ID_MAIN_GADGET_STOP=1, ID_MAIN_PROGIND};
  47.  
  48.  
  49. VOID do_main(VOID)
  50. {
  51.   BOOL close_me=FALSE;
  52.   struct TR_Message *trmsg;
  53.   struct TR_Project *project;
  54.   ULONG i;
  55.  
  56.   if(project=TR_OpenProjectTags(Application,
  57.     WindowID(1),
  58.     WindowTitle("Progress Indicator Demo"),
  59.     WindowPosition(TRWP_CENTERDISPLAY),
  60.     WindowFlags(TRWF_NOCLOSEGADGET|TRWF_NOESCCLOSE),
  61.  
  62.     VertGroupA,
  63.       Space,  CenteredText("Working..."),
  64.       Space,  HorizGroupA,
  65.                 Space, Progress(100,0,ID_MAIN_PROGIND), /* A per cent progress indicator */
  66.                 Space, EndGroup,
  67.       SpaceS,HorizGroupA,
  68.                 Space, HorizGroupSA, TextN("000%"), Space, TextN("050%"), Space, TextN("100%"), EndGroup,
  69.                 Space, EndGroup,
  70.       Space, HorizGroupSA,
  71.                 Space, ButtonE("_Stop",ID_MAIN_GADGET_STOP),
  72.                 Space, EndGroup,
  73.       Space, EndGroup,
  74.  
  75.     EndProject))
  76.   {
  77.     for(i=0;(i<100)&&(!close_me);i++)
  78.     {
  79.       /* Wait 1/5 second. You might want to do some real work here ;) */
  80.  
  81.       Delay(10L);
  82.  
  83.       /* Display our progress */
  84.  
  85.       TR_SetAttribute(project,ID_MAIN_PROGIND,TRAT_Value,i);
  86.  
  87.       /* And Check for the 'Stop' gadget. Note that you always have to include
  88.          such a TR_GetMsg() loop, even if there's no gadget for stopping. You
  89.          have to call TR_GetMsg() regularly so that Triton may react on the
  90.          user's wishes, e.g. redrawing the window contents after a resize. */
  91.  
  92.       while(trmsg=TR_GetMsg(Application))
  93.       {
  94.         if(trmsg->trm_Project==project) switch(trmsg->trm_Class)
  95.         {
  96.           case TRMS_CLOSEWINDOW:
  97.             close_me=TRUE;
  98.             break;
  99.  
  100.           case TRMS_ERROR:
  101.             puts(TR_GetErrorString(trmsg->trm_Data));
  102.             break;
  103.  
  104.           case TRMS_ACTION:
  105.             if(trmsg->trm_ID==ID_MAIN_GADGET_STOP) close_me=TRUE;
  106.         }
  107.         TR_ReplyMsg(trmsg);
  108.       }
  109.     }
  110.     TR_CloseProject(project);
  111.   }
  112.   else puts("Can't open window.");
  113. }
  114.  
  115.  
  116. /* /////////////////////////////////////////////////////////////////////////////////////////////////////// */
  117. /* ////////////////////////////////////////////////////////////////////////////////////// Main function // */
  118. /* /////////////////////////////////////////////////////////////////////////////////////////////////////// */
  119.  
  120. int main(void)
  121. {
  122.   if(TR_OpenTriton(TRITON11VERSION,TRCA_Name,"trProgIndDemo",TRCA_Version,"1.0",TAG_END))
  123.   {
  124.     do_main();
  125.     TR_CloseTriton();
  126.     return 0;
  127.   } else puts("Can't open triton.library v2+.");
  128.  
  129.   return 20;
  130. }
  131.